﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace NewStart
{
    class AnimationHelper
    {
        public static void MoveTiles(FlowLayoutPanel panel, int amount, bool animations)
        {
            try
            {
                //if ((panel.Controls[panel.Controls.Count - 1].Bottom < panel.Height && amount > 0) || (panel.Controls[panel.Controls.Count - 1].Top > 0 && amount < 0))
                {
                    if (SettingsHelper.settings.enableAnimations && animations)
                    {
                        if (amount > 0)
                        {
                            for (int frame = 0; frame < amount; frame++)
                            {
                                foreach (Control control in panel.Controls)
                                    control.Top += 1;

                                Thread.Sleep(1);
                            }
                        }
                        else
                        {
                            int a = -amount;
                            for (int frame = 0; frame < a; frame++)
                            {
                                foreach (Control control in panel.Controls)
                                    control.Top -= 1;

                                Thread.Sleep(1);
                            }
                        }
                    }
                    else
                    {
                        foreach (Control control in panel.Controls)
                            control.Top += amount;
                    }
                }
            }
            catch { }
        }

        public static void MoveApps(FlowLayoutPanel panel, int amount, bool animations)
        {
            try
            {
                if (SettingsHelper.settings.enableAnimations && animations)
                {
                    for (int frame = 0; frame < amount; frame++)
                    {
                        foreach (Control control in panel.Controls)
                            control.Top += 1;

                        Thread.Sleep(1);
                    }
                }
                else
                {
                    foreach (Control control in panel.Controls)
                        control.Top += amount;
                }
            }
            catch { }
        }
    }
}
